﻿{include file="../application/admin/view/common/header.html" /}
        <!--[if lt IE 9]>
          <script src="../js/html5shiv.min.js"></script>
          <script src="../js/respond.min.js"></script>
        <![endif]-->
        <style type="text/css">

            .radio-box{display:inline-block;width: 64px;}
            /* .formControls{padding-right:50px; position: relative;} */
            .textarea {height: 100px;resize: none;font-size: 14px;padding: 4px;}
            .textarea-numberbar {position: absolute;right: 70px;bottom: 5px;z-index: 1;margin-bottom: 0;}
        </style>

        <!--main content start-->
        <section class="main-content">
            <!--start page content-->
            <div class="row">
               
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <div class="tabs">
                                <!-- Nav tabs -->
                                <ul class="list-inline tabs-nav" role="tablist">
									<li role="presentation" num="0" class="active"><a href="#total" aria-controls="total" role="tab" data-toggle="tab" aria-expanded="true">全部</a></li>
                                    <li role="presentation" num="1" class=""><a href="#copyright" aria-controls="copyright" role="tab" data-toggle="tab" aria-expanded="false">专利评议</a></li>
                                    <li role="presentation" num="2" class=""><a href="#trademark" aria-controls="trademark" role="tab" data-toggle="tab" aria-expanded="false">专利维权</a></li>
                                    <li role="presentation" num="3" class=""><a href="#proprietary-technology" aria-controls="proprietary-technology" role="tab" data-toggle="tab" aria-expanded="false">专利托管</a></li>
                                    <li role="presentation" num="4" class=""><a href="#patent" aria-controls="patent" role="tab" data-toggle="tab" aria-expanded="false">专利代理</a></li>
                                    <li role="presentation" num="5" class=""><a href="#policy" aria-controls="policy" role="tab" data-toggle="tab" aria-expanded="false">政策应用</a></li>
                                    <li role="presentation" num="6" class=""><a href="#design" aria-controls="design" role="tab" data-toggle="tab" aria-expanded="false">设计开发</a></li>
                                    <!--<li role="presentation" num="7" class=""><a href="#other" aria-controls="other" role="tab" data-toggle="tab" aria-expanded="false">其他</a></li>-->
                                </ul>
                                <!-- Tab panes -->
                                <div class="tab-content">
                                    <div role="tabpanel" class="tab-pane active" id="copyright">
                                        <div class="row">
                                            <div class="col-md-12">
                                                <div class="panel panel-default collapsed">
                                                    <div class="panel-heading">
													<a class="btn btn-blue ui-w" onclick="all_yes(this)"
                                                   href="javascript:void(0);"><span
                                                        class="ui-icon ui-icon-check"> </span>&nbsp;批量通过</a>
                                                        <label for="name" style="color: #666666;font-size: 16px;font-weight: normal;line-height: 34px;margin: 3px 25px 3px 30px;">状态:
                                                            <select style="height: 34px;border:1px solid #e0e0e0;width: 150px;" name="'status" id="status">
                                                                <option value="0">全部</option>
                                                                <option value="2">待审核</option>
                                                                <option value="3">审核失败</option>
                                                                <option value="1">审核成功</option>
                                                            </select>
                                                        </label>
                                                        <label for="name" style="color: #666666;font-size: 16px;font-weight: normal;line-height: 34px;margin: 3px 0;margin-right: 25px;">类别:
                                                            <select style="height: 34px;border:1px solid #e0e0e0;width: 150px; " name="type" id="type">


                                                            </select>
                                                        </label>

                                                        <div class="float-m" style="display: inline-block;">
                                                            <label>日期范围:</label>
                                                            <input type="text" id="logmin" class="input-text Wdate" style="width:100px;display: inline-block;">
                                                            -
                                                            <input type="text" id="logmax" class="input-text Wdate" style="width:100px;display: inline-block;">
                                                        </div>

                                                        <div class="search-form" style="margin-left:10px;width: 200px; ">
                                                            <input type="text" class="form-control" style="width: 200px;" placeholder="输入商品名" />
                                                            <button type="button" class="btn-search"><i class="fa fa-search"></i></button>
                                                        </div>
                                                    </div>
                                                    <div class="panel-body">

                                                        <table class="table table-hover table-striped table-bordered" data-page-size="12" data-filter=#filter>
                                                            <thead>
                                                            <tr>
                                                                <th><input type="checkbox" id="role"></th>
                                                                <th>ID</th>
                                                                <th>发布店铺</th>
                                                                <th>商品名称</th>
                                                                <th>类别</th>
                                                                <th>价格(￥)</th>
                                                                <th>发布时间</th>
                                                                <th>状态</th>
                                                                <th>操作</th>
                                                            </tr>
                                                            </thead>
                                                            <tbody>




                                                            </tbody>
                                                        </table>
                                                        <div class="pager" id="page" style="text-align: right;"></div>
                                                     </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div><!--end row-->
            
            <!--end page content-->




        </section>
        <!--end main content-->



        <!--Common plugins-->
        <script src="_JS_/jquery.min.js"></script>
        <script src="_JS_/jquery.base64.js"></script>
        <script src="_JS_/jquery.cookie.js"></script>
        <script src="_JS_/bootstrap.min.js"></script>
        <script src="_JS_/jasny-bootstrap.min.js"></script>
        <script src="_JS_/jquery.slimscroll.min.js"></script>
        <script src="_JS_/jquery.nanoscroller.min.js"></script>
        <script src="_JS_/metismenu.min.js"></script>
        <script src="_JS_/float-custom.js"></script>
        <script type="text/javascript" src="_JS_/layer/layer.js"></script>
        <script type="text/javascript" src="_JS_/laypage/laypage.js"></script>
        <script type="text/javascript" src="_JS_/laydata/laydate.js"></script>
        <script type="text/javascript" src="_JS_/getMyDate.js"></script>
        <!-- <script src="js/footable.all.min.js"></script> -->
         <!-- Page-Level Scripts -->
    <script>
        $(function(){
            $("#page-title").html("服务市场管理");
            get_sort(1);
            service_list(1,0);
        });
        $('.tabs ul li').on('click',function(){
               // var index = parseInt($(".tabs ul li").index(this))+1;
			 
            var index=$(this).attr('num');
                get_sort(index);
                service_list(1,index);
        });
        $('#type').on('change',function(){
            //var index = parseInt($(".tabs ul li").index($(".tabs ul li[class='active']")))+1;
            var index =$(".tabs ul li[class='active']").attr('num');
            service_list(1,index);
        });
        $('#status').on('change',function(){
            //var index = parseInt($(".tabs ul li").index($(".tabs ul li[class='active']")))+1;
            var index =$(".tabs ul li[class='active']").attr('num');
            service_list(1,index);
        });
        // 搜索
        $('.btn-search').click(function () {
            var index =$(".tabsul li[class='active']").attr('num');
            service_list(1,index);
        });

        //回车键绑定搜索
        $(".search-form").keydown(function (event) {
            if (event.keyCode == 13) {
                var index =$(".tabs ul li[class='active']").attr('num');
                service_list(1,index);
            }
        });
        function get_sort(index){
            $.ajax({
                type: 'GET',
                url: "{:url('api/service/get_type')}",
                data:{'type':index},
                dataType: 'jsonp',
                jsonp: 'callback',
                success: function (msg) {
                    $("#type").html('');
                    if (msg.code == 200) {
                        if (msg.data.length > 0) {
                            var text='<option value="0">全部</option>';
                            for (var j = 0; j < msg.data.length; j++) {
                                text += '<option value="' + msg.data[j].id + '">' + msg.data[j].t_name + '</option>';
                            }
                        }
                        $("#type").html(text);
                    }
                }
            });
        }
        function service_list(page,index){
            var logmin = $("#logmin").val();
            var logmax = $("#logmax").val();
            var status = $("#status").val();
            var name=$('.form-control').val();
            var type=$("#type").val();
            $.ajax({
                type: 'GET',
                url: "{:url('api/service/index')}",
                data:{'number':10,'logmin':logmin,'logmax':logmax,'type':type,'index':index,'name':name,'status':status,'page':page},
                dataType: 'jsonp',
                jsonp: 'callback',
                success: function (msg) {
                    if (msg.code == 200) {
                        var pages=Math.ceil(msg.data.count/10);
                        $("tbody").html('');
                        if (msg.data.data.length > 0) {
                            for (var i = 0; i < msg.data.data.length; i++) {
                                var time = msg.data.data[i].add_time;
                                ltime=getMyDate(time*1000);
                                var html='<tr id="' + msg.data.data[i].id + '"><td><input class="checked" type="checkbox" name=""></td>';
                                html+='<td>'+msg.data.data[i].id+'</td><td>'+msg.data.data[i].shop_name+'</td>';
                                html+='<td>'+msg.data.data[i].goods_name+'</td><td>'+msg.data.data[i].t_name+'</td>';
                                html+='<td>'+msg.data.data[i].price+'</td>';
                                html+='<td>'+ltime+'</td>';
                                if(msg.data.data[i].status==2){
                                    html+='<td class="td-status enable">待审核</td>';
                                    html+='<td class="buttons td-manage">';
                                    html+='<a class="btn table-btn goods_pass" onclick="goods_pass(this,'+msg.data.data[i].id+')" href="javascript:;" title="通过"><i class="fa fa-check"></i></a>';
                                    html+='<a class="btn table-btn goods_nopass" onclick="goods_nopass(this,'+msg.data.data[i].id+')" href="javascript:;" title="不通过"><i class="fa fa-times"></i></a>';
                                }else if(msg.data.data[i].status==1){
                                    html+='<td class="td-status pass">审核通过</td>';
                                    html+='<td class="buttons td-manage">';
                                }else{
                                    html+='<td class="td-status disable">审核不通过</td>';
                                    html+='<td class="buttons td-manage">';
                                }
                                html+='<a class="btn table-btn" onclick="goods_msg(this,'+msg.data.data[i].id+')" href="#" title="查看详情"><i class="fa fa-ellipsis-h"></i></a>';
                                html+='</td></tr>';
                                $(".table tbody").append(html);

                            }

                        }
                        $(".table").attr("pages",page);
                        //分页
                        laypage({
                            cont: 'page',
                            pages: pages,
                            curr:page,
                            jump: function(obj,first){
                                if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr
                                    service_list(obj.curr,index);
                                }
                            }
                        })

                    }
                    if (msg.code == 1000) {
                        layer.msg("加载信息失败！");
                    }
                }
            });
        }

    
    //商品信息
    function goods_msg(obj,id){
        layer.open({
            type: 2,
            title: '商品信息',
            shadeClose: true,
            shade: 0.8,
            area: ['700px', '700px'],
            content: 'goods_msg.html#'+id
        }); 
    }
    
	
	
    /*全选*/
    $("#role").change(function () {
        if ($(this).prop('checked')) {
            $("#role").prop('checked', true);
            $('.checked').prop('checked', true);
        } else {
            $("#role").prop('checked', false);
            $('.checked').prop('checked', false);
        }
    });

    function all_yes(obj) {
        var arrs = [];
        $('tbody input:checked').parents('tr').each(function () {
            arrs.push($(this).attr('id'));
        });
        if (arrs.length == 0) {
            layer.msg('请选择需要取消的!', {icon: 1, time: 1000});
            return false;
        }
        var ids = arrs.join(",");
        goods_pass(obj, ids);
    }
	
    /*通过审核*/
    function goods_pass(obj,id){
        layer.confirm('确认该商品通过审核吗？',function(index){
   //         var pages_num=$(".table").attr("pages");
            $.ajax({
                type: "get",
                url: "{:url('api/service/goods_del')}",
                dataType: 'jsonp',
                jsonp:'callback',
                data: {'id':id,'status':'1'},
                success: function (msg) {
                    if(msg.code == 200){
						$("#role").prop('checked', false);
                        -->
						layer.msg('已通过审核!',{icon: 1,time:1000});
						var index=  $(".tabs ul li[class='active']").attr('num');
			 
                        service_list(1,index);
                    }
                    if(msg.code==1000){
                        layer.msg('删除失败!',{icon:5,time:1000});
                    }
                }
            });
        });
    }

    /*不通过审核*/
    function goods_nopass(obj,id){
        layer.confirm('确认该商品不通过审核吗？',function(index){
            //此处请求后台程序，下方是成功后的前台处理……
            layer.close(index);
            layer.prompt({title: '审核不通过原因', formType: 2}, function(text, index){
    //            var pages_num=$(".table").attr("pages");
                $.ajax({
                    type: "get",
                    url: "{:url('api/service/goods_del')}",
                    dataType: 'jsonp',
                    jsonp:'callback',
                    data: {'id':id,'status':'3','reason':text},
                    success: function (msg) {
                        if(msg.code == 200){
                            layer.close(index);
                            layer.msg('审核不通过!',{icon: 2,time:1000});
							var index=  $(".tabs ul li[class='active']").attr('num');
                            service_list(1,index);
                        }
                        if(msg.code==1000){
                            layer.msg('删除失败!',{icon:5,time:1000});
                        }
                    }
                });

            });
        });
    }


    //日期范围限制
    var start = {
        elem: '#logmin',
        format: 'YYYY-MM-DD',
        min: '1970-01-01', //设定最小日期为当前日期
        max: laydate.now(), //最大日期
        istime: false,
        istoday: false,
        choose: function(datas){
             end.min = datas; //开始日选好后，重置结束日的最小日期
             end.start = datas //将结束日的初始值设定为开始日
        }
    };

    var end = {
        elem: '#logmax',
        format: 'YYYY-MM-DD',
        min: '1970-01-01',
        max: laydate.now(),
        istime: false,
        istoday: false,
        choose: function(datas){
            start.max = datas; //结束日选好后，充值开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);
    </script>
    </body>
</html>